class CartItem 

  attr_reader :quantity 
  
  def initialize(article)
    @article_id = article.id
    @quantity = 1
    @price = article.price
  end

  def increase_quantity
    @quantity+=1
  end

  def decrease_quantity
    unless @quantity<=1
      @quantity-=1
    else
      @quantity = 0
    end
  end

  def price
    @price * @quantity
  end
  
  def article
    Article.find(@article_id)
  end

end